from django.shortcuts import render
from django.http import HttpResponse
from app2 import models
import uuid
# Create your views here.


def create(request):
	dept_obj =models.Department.objects.filter(Name='深圳中原').first()
	dic = {
		'KeyId': uuid.uuid1(),
		'Name': '深圳王五',
		'Age': 22,
		'DeptKeyId': dept_obj,
		'Version': 1,
		'IsDelete': 0,
	}
	models.UserInfo.objects.create(**dic)

	dic = {
		'KeyId': uuid.uuid1(),
		'Name': '广州王五',
		'Age': 22,
		'DeptKeyId_id': 'cd639b0a-583c-11e9-b0a5-3085a91c62af',
		'Version': 1,
		'IsDelete': 0,
	}
	models.UserInfo.objects.create(**dic)

	return HttpResponse('OK');

def delete(request):
	dept_obj =models.Department.objects.filter(Name='深圳中原').first()
	dic = {
		'DeptKeyId': dept_obj,
		'Age': 22,
	}
	obj = models.UserInfo.objects.filter(**dic).delete();
	print(obj)

	return HttpResponse('OK');

def find(request):

	return HttpResponse('OK');

def update(request):

	return HttpResponse('OK');






def demo(request):
	dic = {
		'KeyId': uuid.uuid1(),
		'Name': '北京中原',
		'Version': 1,
		'IsDelete': 0,
	}
	models.Department.objects.create(**dic);
	dic['KeyId'] = uuid.uuid1()
	dic['Name'] = '深圳中原'
	models.Department.objects.create(**dic);
	dic['KeyId'] = uuid.uuid1()
	dic['Name'] = '广州中原'
	models.Department.objects.create(**dic);

	return HttpResponse('OK');